﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class IndexIntervalElement : SyntaxTreeElement
    {
        private List<FunctionVarDeclarationElement> vars;

        public List<FunctionVarDeclarationElement> Vars { get { return vars; } set { vars = value; } }

        public IndexIntervalElement(TokenInfo StartInfo, List<FunctionVarDeclarationElement> Vars, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            vars = Vars;
        }

        public override string ToString()
        {
            return ((vars != null) && (vars.Count > 0)) ? string.Format("[{0}]", vars.Join("; ")) : string.Empty;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (vars != null)
                foreach (FunctionVarDeclarationElement var in vars)
                    yield return var;
        }
    }
}
